package metier;


import javax.persistence.*;

import org.hibernate.*;

import requetesHQL.UserHQL;

import configuration.HibernateUtil;

@Entity
@Table(name = "utilisateur")
public class User {
	
	@Id
	@Column(name = "loginuser")
    private String login;
	
	@Column(name = "mdpuser")
    private String pwd;
	
	@Column(name = "roleuser")
    private String roleUser;
    
    public User() {
    	super();
    }

    public User(String login, String pwd){
    	setLogin(login);
    	setPwd(pwd);
    	this.roleUser = "";
    }
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getRoleUser(){
		return roleUser;
	}
	public void setRoleUser(String roleUser){
		this.roleUser = roleUser;
	}
	
	public void ajouterUserTest(){
		Session session = HibernateUtil.getSession();
		Transaction trans = session.beginTransaction();
		User lUser = new User("Camille", "barret");
		session.persist(lUser);
		trans.commit();
		session.close();
	}
	
	public boolean verifConnexion(String login, String pwd){
		UserHQL userRequete = new UserHQL(this);
		boolean possible = userRequete.requeteVerifConnexion();
		return possible;
	}
}
